<html>
<head>
<script type="text/javascript" src="./jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="./jquery-ui-1.8.9.custom.min.js"></script>
<link type="text/css" rel="stylesheet" media="all"
	href="./jquery-ui-1.8.9.custom.css" />
<script type="text/javascript" src="./jquery.validate.js"></script>
<script type="text/javascript" src="./header.js"></script>
<script type="text/javascript" src="./sort.js"></script>
<script type="text/javascript" src="./jquery.cookie.js"></script>
<script type="text/javascript" src="./cookie-service.js"></script>
<script type="text/javascript" src="./auto-complete.js"></script>
<link type="text/css" rel="stylesheet" media="all" href="./simple.css" />
<script type="text/javascript">
	function sortByRating(x, y) {
		return x.rating - y.rating;
	}

	$(document)
			.ready(
					function() {
						setPrintParams('Company :', [ 'Company Name',
								'companyName', 'Rating', 'rating',
								'Headquarters', 'headquarters', 'Industry',
								'industryName', 'Locations', 'locations' ]);
						setFilterParams([ 'cSId', 'locationId' ], [
								'companyName', 'locations' ]);
						$.get("http://localhost:8085/poc/getAllCompanies.htm",
								handleJson, "html");
						setAutoComplete([ 'locationId', 'location' ]);
						setTimeout(setAutoCompleteForCompanyName, 5000);
					});

	function postProcess(par, obj) {
		var element = document.createElement("a");
		element.setAttribute("href", "CompanyD.htm?companyId="
				+ obj['companyId']);
		var text = document.createTextNode("Company Page");
		element.appendChild(text);
		par.appendChild(element);
	}

	function setAutoCompleteForCompanyName() {
		var obj = getJsonObject();
		var companyNames = new Array();
		var index = 0;
		$.each(obj, function() {
			companyNames[index++] = this['companyName'];
		});
		setAutoCompleteWithValue('cSId', companyNames);
	}
</script>
</head>
<body>
	<div id="header"></div>
	<h2>Search Company</h2>
	<form id="form1" name="searchC" action="searchCompanyD.htm"
		method="get">
		<div class="form-row">
			<span class="label">Company Name: </span><input type="text"
				name="cSName" id="cSId" />
		</div>
		<div class="form-row">
			<span class="label">Location: </span><input type="text"
				name="locationName" id="locationId" />
		</div>
		<div class="form-row">
			<input class="submit" type="button" Value="filter" onclick="filter()">
		</div>

		<div class="form-row">
			<span class="label">Sort By : </span><select name="sortId"
				id="sortId">
				<option value="R">Rating</option>
			</select>
		</div>
		<div class="form-row">
			<input class="submit" type="button" Value="Sort"
				onclick="sort(sortByRating)">
		</div>

		<div id="abc"></div>
	</form>
</body>
</html>